<template>
  <div>
    <div id="box">
      <header>
        <div>
          <img src="/static/img/back.png" alt="" @click="backClick">
          <span>登录</span>
        </div>
        <div>
          <img src="/static/img/客服.png" alt="">
          <img src="/static/img/更多01.png" alt="">
        </div>
      </header>
      <main>
        <div id="account">
          <div class="cell">
            <label>账号：</label>
            <input type="text" placeholder="邮箱/手机号登录" v-model="username">
          </div>
          <div class="cell">
            <label>密码：</label>
            <input type="password" placeholder="请输入密码" v-model="psw">
          </div>
        </div>
        <div id="login">
          <div class="center" id="one">
            <div>
              <input type="checkbox">
              <span id="remember">记住密码</span>
            </div>
            <a href="">忘记密码？</a>
          </div>
          <div id="lgrg">
            <button @touchstart="registClick">快速注册</button>
            <button @touchstart="btnClick">登录</button>
          </div>
          <div id="msg">
            <a href="">短信快捷登录</a>
          </div>
        </div>
        <div id="otherlogin">
          <img src="/static/img/第三方登录.png" alt="">
        </div>
      </main>
    </div>
  </div>
</template>

<script>
  export default {
    methods: {
      backClick: function () {
        history.back()
      },
      registClick:function () {
        location.hash = '/regist'
      },
      btnClick: function () {
        let param = {
          username: this.username,
          psw: this.psw
        };
        this.http.post("/api/users/login", param)
          .then(res => {
            this.$layer.msg(res.data.msg);
            if (!res.data.err) {
              let jsonStr = JSON.stringify(res.data.data)
              localStorage.setItem('usermsg',jsonStr)
              location.hash = '/'
            }
          })
      }
    },
    data: function () {
      return {
        username: "",
        psw: ""
      }
    },
    computed: {

    }
  }
</script>

<style scoped>
  #box {
    height: 100vh;
    background-color: rgb(245, 245, 245);
  }

  header {
    background-color: rgb(0, 71, 156);
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
  }
  header div{
    display: flex;
    align-items: center;
  }
  header div span{
    color: white;
    margin-left: 12px;
    position: relative;
    top: -2px;
  }

  main {
    margin-top: 24px;
  }

  #account {
    background-color: white;
    padding: 10px 30px;
    border-bottom: 1px solid #dddddd;
    border-top: 1px solid #dddddd;
  }

  .cell {
    background-color: white;
    padding: 6px 0;
  }

  input {
    border: none;
    border-bottom: solid 1px #dddddd;
    width: 70vw;
    margin-bottom: 8px;
    height: 30px;
    padding: 4px;
  }

  label {
    font-size: 15px;
    color: #444444;
  }

  #one {
    display: flex;
    justify-content: space-between;
  }

  #one input {
    width: 16px;
    height: 16px;
  }

  #login {
    padding: 6px 30px;
  }

  #login a {
    color: rgb(0, 71, 156);
    font-size: 14px;
    text-decoration: none;
  }
  #remember{
    font-size: 14px;
    position: relative;
    top: -4px;
  }
  button {
    width: 44%;
    height: 36px;
    background-color: rgb(230, 27, 116);
    border: none;
    border-radius: 6px;
    margin: 6px 0;
    color: white;
    font-size: 15px;
  }
  button:nth-of-type(1){
    color: #2f2f2f;
    background-color: white;
    border: solid 1px #b0b0b0;
  }

  #msg {
    text-align: right;
    padding-top: 12px;
  }

  #lgrg{
    display: flex;
    justify-content: space-between;
  }
  #otherlogin{
    text-align: center;
  }
</style>
